package system;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@WebServlet("/getUserInf")
public class getUserInf extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		HttpSession session=req.getSession();
        String userid=(String)session.getAttribute("userid");
        
        sqlOperation sql = new sqlOperation();
        
        String[] inf=sql.getQueryLine("select * from user_inf where user_id='"+userid+"'",5);
        
        String result="{\"userName\":\""+inf[2]+"\",\"email\":\""+inf[3]+"\",\"userType\":\""+inf[4]+"\"}";
         
        resp.setContentType("application/json;charset=UTF-8");
 		PrintWriter out = resp.getWriter();		
 		out.write(result);
        
	}
}
